home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 January: Mac OS SDK / Dev.CD Jan 00 SDK1.toast / Development Kits / Mac OS / Security SDK / Documents / Keychain API Changes < prev    next >
Encoding:
Text File  |  1999-10-28  |  7.2 KB  |  99 lines  |  [ttro/ttxt]

  1.  
  2.  
  3. Keychain Manager 2.0 API Changes
  4.  
  5. This document describes changes to the Keychain Manager API from version 1.0.1 to 2.0. If your application is currently using the Keychain 1.0.1 SDK, you must read this document.
  6.  
  7. Introduction
  8.  
  9. In the year since the Keychain Manager SDK was initially released to developers, a number of significant changes have been made to the application programming interfaces (API) in order to accomodate additional features in the Keychain software. In general, applications which only make use of the high-level routines provided in Keychain 1.0 (such as KCFindInternetPassword) will run unmodified under Keychain 2.0. However, some applications may need to be revised for compatibility with Keychain 2.0, depending on their usage of certain low-level API calls. This document details the API calls which have changed, and discusses potential compatibility issues for developers using the 1.0.1 SDK. It is not intended for developers already using the 2.0 SDK.
  10.  
  11. Specifying keychains
  12.  
  13. Keychain specification records are no longer part of the API. Instead, an opaque KCRef data type is always used to reference a keychain. There are two new functions to specify a file-based keychain (given an FSSpec or an alias handle), and accessor functions to retrieve properties of a keychain (such as its name.) To be safe, your application should never assume that a given keychain is a file or that its storage is local. While the first release of the Keychain Manager only deals with file-based keychains, future versions will support keychains on smart cards and other media. Using keychain references instead of fixed specification records will make this transition as transparent as possible. Developers currently using the 1.0 API need to be aware of the following issues:
  14.  
  15. • The KCSpec data type is obsolete. Your application should no longer allocate KCSpec records or pass a KCSpec by reference to any Keychain Manager routine. Certain 1.0 API routines which accepted a KCSpec parameter will continue to function correctly when running under Keychain 2.0 (including KCGetActiveKeychain, KCSetActiveKeychain, KCUnlockKeychain, and KCLockKeychain), but you should avoid using these routines if possible and update your code to use the equivalent routines provided in the 2.0 API.
  16.  
  17. • Your application should call KCGetDefaultKeychain instead of KCGetActiveKeychain if it needs to determine the current keychain.
  18.  
  19. • You should use the KCGetKeychainName function to obtain the name of a given keychain, instead of examining the kcFileSpec.name field of a KCSpec structure.
  20.  
  21. • You should always use a KCRef to reference a keychain. A valid KCRef is obtained from one of the following routines:
  22.  
  23.   KCMakeKCRefFromFSSpec(FSSpec *keychainFSSpec, KCRef *keychain);
  24.   KCMakeKCRefFromAlias (AliasHandle keychainAlias, KCRef *keychain);
  25.   KCGetDefaultKeychain (KCRef *keychain);
  26.   KCCreateKeychain (StringPtr password, KCRef *keychain);
  27.   KCGetKeychain (KCItemRef item, KCRef *keychain);
  28.   KCGetIndKeychain (UInt16 index, KCRef *keychain);
  29.  
  30.  
  31. NOTE You can pass a KCRef with a value of NIL to specify the default keychain.
  32.  
  33. The following routines formerly referenced keychains using a pointer to a KCSpec record, and now expect a KCRef argument instead:
  34.  
  35.   KCUnlockKeychain       (deprecated - use KCUnlock instead)
  36.   KCLockKeychain         (deprecated - use KCLock instead)
  37.   KCGetActiveKeychain    (deprecated - use KCGetDefaultKeychain instead)
  38.   KCSetActiveKeychain    (deprecated - use KCSetDefaultKeychain instead)
  39.   KCGetStartupKeychain   (obsolete)
  40.   KCSetStartupKeychain   (obsolete)
  41.   KCGetStatus
  42.   KCGetIndKeychain
  43.  
  44. Getting the status of a keychain
  45.  
  46. The enumerated constant kLockStateKCStatus has been changed to kUnlockStateKCStatus since that particular bit, if set, indicates that a keychain is unlocked. The following C code snippet illustrates how to examine the status of the default keychain:
  47.  
  48.   Boolean  kcIsUnlocked;
  49.   Boolean  kcHasWriteAccess;
  50.   UInt32   kcStatus;
  51.   OSStatus status;
  52.  
  53.   status = KCGetStatus(nil, &kcStatus);
  54.   if (status == noErr) {
  55.     kcIsUnlocked = (kcStatus & kUnlockStateKCStatus);
  56.     kcHasWriteAccess = (kcStatus & kWrPermKCStatus);
  57.   }
  58.  
  59. "Active" keychain is now "default"
  60.  
  61. Keychain 2.0 allows multiple keychains to be unlocked at once, so the terminology of a single "active" keychain was inappropriate. The "default" keychain is defined as the one into which new items are added, and the preferred keychain to unlock at startup. While the routines KCGetActiveKeychain and KCSetActiveKeychain remain implemented in 2.0, they require the use of the obsolete KCSpec data type. Your application should call KCGetDefaultKeychain or KCSetDefaultKeychain instead if it needs to determine or change the current keychain.
  62.  
  63. No more "startup" keychain
  64.  
  65. The "startup" keychain concept in Keychain 1.0 has been removed from the API. Responsibility for automatically unlocking the default keychain at startup (formerly controlled by the API routine KCSetStartupKeychain) has been moved to another part of the system software. The implications of this change for the 2.0 API are:
  66.  
  67. • The routine KCSetStartupKeychain is no longer implemented, and will return an error.
  68. • The routine KCGetStartupKeychain is no longer implemented, and will return an error.
  69.  
  70. No more "flags" attribute
  71.  
  72. The attribute kFlagsKCItemAttr has been removed, along with the KCItemFlags constants. Instead, the characteristics which were formerly specified by setting bits in this attribute are now full-fledged boolean attributes: kInvisibleKCItemAttr, kNegativeKCItemAttr, and kCustomIconKCItemAttr. This was done so that a search can be performed on each attribute individually. The implications of this change for the 2.0 API are:
  73.  
  74. • The routine KCNewItem no longer takes an itemFlags parameter. Applications which call KCNewItem must be revised to call this routine with the new 2.0 interface.
  75. • Applications which set the "custom icon" flag (in order to display a custom item icon in Keychain Access) will instead need to set the kCustomIconKCItemAttr attribute.
  76.  
  77. No more user names
  78.  
  79. A user name is no longer a property of a keychain. This allows a keychain to be used by more than one person on a multiple-user system, or where access to a keychain is determined by some means other than user name & password (such as the insertion of a hardware token.) The implications of this change for the 2.0 API are:
  80.  
  81. • The routine KCCreateKeychain no longer takes a userName parameter. Applications which call KCCreateKeychain must be revised to call this routine with the new 2.0 interface.
  82. • The routine KCGetUserName is no longer implemented and will return an error.
  83.  
  84. Keychain settings changes
  85.  
  86. The KCSetLockInterval and KCGetLockInterval calls have been removed for security reasons. Applications should never have had a reason to call these routines.
  87.  
  88. The routine KCChangeIdentity has been renamed to KCChangeSettings. This call requires the user to re-authenticate before bringing up the dialog for changing the keychain settings. Your application should normally never need to call this routine.
  89.  
  90. Error code changes
  91.  
  92. • The error errKCNoActiveKeychain has been renamed to errKCNoDefaultKeychain.
  93. • The error errKCNoStartupKeychain is obsolete and has been removed.
  94.  
  95.  
  96. Last modified: 28 July 1999
  97.  
  98. © 1999 Apple Computer, Inc.